package Retorfit对象;

import java.util.List;

import Bean.ArticleBean;
import Bean.LoginBean;
import Two_interface.GetArticleListInfoService;
import Two_interface.GetLoginReturnInfo;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by pc on 2017/5/26.
 */

public abstract  class LoginModel {
    private static final String BASE_URL = "http://amicool.neusoft.edu.cn/";
    Retrofit retrofit;

   public LoginModel(){
        retrofit =new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl(BASE_URL)
                .build();
    }

    public void MakeAAsk(String username,String password){

        GetLoginReturnInfo getLoginReturnInfo =retrofit.create(GetLoginReturnInfo.class);
        Call<LoginBean> call=getLoginReturnInfo.getLoginResult(username,password);
        Ask_A_ask(call);
    }
    public void  Ask_A_ask(Call<LoginBean> call){
        call.enqueue(new Callback<LoginBean>() {
            @Override
            public void onResponse(Call<LoginBean> call, Response<LoginBean> response) {
                LoginonResponse(call,response);
            }

            @Override
            public void onFailure(Call<LoginBean> call, Throwable t) {
            LoginonFailure(call,t);
            }
        } );
    }
    public abstract void LoginonResponse(Call<LoginBean> call, Response<LoginBean> response);
    public abstract void LoginonFailure(Call<LoginBean> call, Throwable t);

}
